package com.tang.partition;

import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * 自定义分区
 *
 * @author tang
 * @since 2023/6/8 18:03
 */
public class PartitionCustomDemo {

    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironmentWithWebUI(new Configuration());
        env.setParallelism(2);

        DataStreamSource<String> source = env.socketTextStream("192.168.70.141", 7777);
        source.partitionCustom(new MyPartitioner(), r -> r).print();

        env.execute();
    }
    
}
